/**
 * @(#)MailController.java, 2010-5-16. 
 * 
 * Copyright 2010 Youdao, Inc. All rights reserved.
 * YOUDAO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.rsstuan.web.cron.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.rsstuan.mail.MailSender;
import com.rsstuan.utils.CityUtils;
import com.rsstuan.web.controller.SpringController;

/**
 *
 * @author guosq
 *
 */
public class MailController extends SpringController {
    
    private MailSender sender;
    
    public ModelAndView sendDailyMail(HttpServletRequest request,
            HttpServletResponse response) throws IOException  {

            String cityid = request.getParameter("cityid");
            String city = CityUtils.getCityString(cityid);
            String type = request.getParameter("type");
            if (type != null) {
            	if (type.equals("test")) {
            		sender.sendDailyMailTest(city);
            	}
            	else if (type.equals("manual")) {
            		sender.sendDailyMail(city);
            	}
            }
            response.getWriter().write("Send Daily Mail Success, type=" + type);

        return null;
    }

    public void setSender(MailSender sender) {
        this.sender = sender;
    }
    
    

}
